package adv2;

import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;

public class Remove2 {

	public static void main(String[] args) {

		List list = new LinkedList();

		for (int i = 0; i < 20; i++) {
			list.add((int) (Math.random() * 20 + 1));
		}
		System.out.println(list);
		System.out.println(">>>>>>>>>>>>");
		List l2 = new LinkedList();// 存放处理去重后的结果
		for (int i = 0; i < list.size(); i++) {
			Object o = list.get(i);//
			int count = 0;
			// 判断o在这个集合中出现的次数，超过一次认为有重复
			for (int j = 0; j < list.size(); j++) {
				if (list.get(j).equals(o))
					count++;
			}
			if (count == 1)
				l2.add(o);
		}

		System.out.println("去重后剩下的：" + l2);

	}

}
